package br.cnpq.webflowah.gui;

import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.WindowConstants;
import javax.swing.JDialog;
import javax.swing.BorderFactory;

import br.cnpq.webflowah.beans.Conceito;
import br.cnpq.webflowah.beans.Objetivo;
import br.cnpq.webflowah.beans.WorkflowSemantico;
import br.cnpq.webflowah.ontologia.ConceitoOWL;
//import br.cnpq.webflowah.ontologia.ServicoOWL;

public class TelaAssistenteWorkflow extends JDialog {

	private static final long serialVersionUID = 1L;

	private List<JPanel> listPanels = null;  //  @jve:decl-index=0:

	private int currentPanel = 0;

	private int opcao = 0;

	private JPanel jToolBarPane = null;

	private JButton voltarButton = null;

	private JButton avancarButton = null;

	private JButton encerrarButton = null;

	private JButton cancelarButton = null;

	private JPanel jContentPane = null;

	private JPanel jCenterPane = null;

	private JLabel jLabel1 = null;

	private JLabel jLabel2 = null;

	private JPanel jPanel1 = null;

	private JScrollPane jScrollPane1 = null;

	private JList jList1 = null;

	private JScrollPane jScrollPane2 = null;

	private JList jList2 = null;

	private JPanel jPanel2 = null;

	private JPanel jPanel21 = null;

	private JLabel jLabel21 = null;

	private JPanel jPanel22 = null;

	private JLabel jLabel3 = null;

	private JLabel jLabel4 = null;

	private JScrollPane jScrollPane3 = null;

	private JList jList3 = null;

	private JScrollPane jScrollPane4 = null;

	private JList jList4 = null;

	private JPanel jPanel3 = null;

	private JPanel jPanel31 = null;

//	private JButton jButton = null;

	private JLabel jLabel31 = null;

	private JPanel jPanel32 = null;

	private JLabel jLabel5 = null;

	private JLabel jLabel6 = null;

	private JScrollPane jScrollPane5 = null;

	private JList jList5 = null;

	private JScrollPane jScrollPane6 = null;

	private JList jList6 = null;

	private WorkflowSemantico workflow = null;  //  @jve:decl-index=0:

	private Objetivo objetivo = null;

	private JLabel jLabel32 = null;

	private JScrollPane jScrollPane31 = null;

	private JList jList31 = null;

	private JScrollPane jScrollPane41 = null;

	private JList jList41 = null;

	private JLabel jLabel41 = null;

	private JScrollPane jScrollPane51 = null;

	private JList jList51 = null;

	private JLabel jLabel51 = null;

	private JScrollPane jScrollPane61 = null;

	private JList jList61 = null;

	private JLabel jLabel61 = null;

//	private JLabel jLabel = null;

	/**
	 * @param owner
	 */
	private TelaAssistenteWorkflow(Frame owner) {
		super(owner, "Assistant Workflow", true);
		initialize();
	}

	public static WorkflowSemantico criarWorkflow(Frame parent, WorkflowSemantico workflow) {
		TelaAssistenteWorkflow tela = new TelaAssistenteWorkflow(parent);
		tela.workflow = (workflow == null) ? new WorkflowSemantico() : workflow;
		tela.setVisible(true);
		if (tela.opcao == JOptionPane.OK_OPTION) return tela.workflow;
		return null;
	}

	public static Objetivo criarObjetivo(Frame parent, WorkflowSemantico workflow) {
		TelaAssistenteWorkflow tela = new TelaAssistenteWorkflow(parent);
		tela.workflow = (workflow == null) ? new WorkflowSemantico() : workflow;
//		tela.jButton.setVisible(false);
		tela.setVisible(true);
		if (tela.opcao == JOptionPane.OK_OPTION) return tela.objetivo;
		return null;
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	//Iniciando a janela
	private void initialize() {
		this.setSize(500, 700);
		this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		this.setContentPane(getJContentPane());
		this.addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosing(java.awt.event.WindowEvent e) {
			}
			public void windowOpened(java.awt.event.WindowEvent e) {
				populateJList1();
			}
		});
		this.setLocationRelativeTo(null);

		this.listPanels = new ArrayList<JPanel>();
		this.listPanels.add(getJPanel1());
		this.listPanels.add(getJPanel2());
		this.listPanels.add(getJPanel3());
	}

	//preenchendo a lista do assistente, fazendo leitura na ontologia
	//pegando os conceitos
	private void populateJList1() {
		DefaultListModel model = (DefaultListModel) jList1.getModel();
		model.removeAllElements();

		List list = ConceitoOWL.recuperarTodos(ConceitoOWL.OWL_CLASS_TAREFA);
		for (int i = 0; list != null && i < list.size(); i++)
			model.addElement(list.get(i));
	}

	private void populateJList2(int index) {
		DefaultListModel model = (DefaultListModel) jList2.getModel();
		model.removeAllElements();

		if (index < 0) return;
		//retorna os conceitos apartir do index, que representa o item selecionado.
		Conceito tarefa = (Conceito) jList1.getModel().getElementAt(index);
		//busca apartir da entrada
		List list = ConceitoOWL.recuperarObjetos(tarefa);
		for (int i = 0; list != null && i < list.size(); i++)
			model.addElement(list.get(i));
	}

	private void populateJList3(Objetivo objetivo) {
		DefaultListModel model = (DefaultListModel) jList3.getModel();
		model.removeAllElements();

		if (objetivo == null) return;

		List entradas = ConceitoOWL.recuperarEntradas(objetivo.getTarefa(),
				objetivo.getObjeto(), workflow.getEntradasWorkflow(),
				workflow.getSaidasWorkflow());

		for (int i = 0; entradas != null && i < entradas.size(); i++) {
			Conceito conceito = (Conceito) entradas.get(i);
			model.addElement(conceito);
		}
	}

	private void populateJList4(Objetivo objetivo) {
		DefaultListModel model = (DefaultListModel) jList4.getModel();
		model.removeAllElements();

		if (objetivo == null)
			return;

		List<URI> filtro = workflow.getSaidasWorkflow();

		List saidas = ConceitoOWL.recuperarSaidas(objetivo.getTarefa(),
				objetivo.getObjeto(), filtro);
		for (int j = 0; saidas != null && j < saidas.size(); j++) {
			Conceito conceito = (Conceito) saidas.get(j);
			model.addElement(conceito);
		}
	}

	//Esse m�todo chama o m�todo concieotOWL.recuperarPreCondicoes
	//para solicitar

	private void populateJList31(Objetivo objetivo) {
		DefaultListModel model = (DefaultListModel) jList31.getModel();
		model.removeAllElements();

		if (objetivo == null)
			return;

		List precondicoes = ConceitoOWL.recuperarPreCondicoes(objetivo.getTarefa(),
				objetivo.getObjeto(), workflow.getPrecondicoes());
		for (int j = 0; precondicoes != null && j < precondicoes.size(); j++) {
			Conceito condicao = (Conceito) precondicoes.get(j);
			model.addElement(condicao);
		}
	}

	//recuper efeito na tela de assitente
	private void populateJList41(Objetivo objetivo) {
		DefaultListModel model = (DefaultListModel) jList41.getModel();
		model.removeAllElements();

		if (objetivo == null)
			return;

		List efeitos = ConceitoOWL.recuperarEfeitos(objetivo.getTarefa(),
				objetivo.getObjeto(), workflow.getEfeitos());
		for (int j = 0; efeitos != null && j < efeitos.size(); j++) {
			Conceito efeito = (Conceito) efeitos.get(j);
			model.addElement(efeito);
		}
	}

	private void populateJList5(int[] idx) {
		DefaultListModel model = (DefaultListModel) jList5.getModel();
		model.removeAllElements();

		for (int i = 0; i < idx.length; i++) {
			Conceito conceito = (Conceito) jList3.getModel().getElementAt(idx[i]);
			if ("----- Principais -----".equals(conceito.toString())
					|| "----- Auxiliares -----".equals(conceito.toString())) continue;
			model.addElement(conceito);
		}
	}

	private void populateJList6(int[] idx) {
		DefaultListModel model = (DefaultListModel) jList6.getModel();
		model.removeAllElements();

		for (int i = 0; i < idx.length; i++)
			model.addElement(jList4.getModel().getElementAt(idx[i]));
	}

	private void populateJList51(int[] idx) {
		DefaultListModel model = (DefaultListModel) jList51.getModel();
		model.removeAllElements();

		for (int i = 0; i < idx.length; i++)
			model.addElement(jList31.getModel().getElementAt(idx[i]));
	}

	private void populateJList61(int[] idx) {
		DefaultListModel model = (DefaultListModel) jList61.getModel();
		model.removeAllElements();

		for (int i = 0; i < idx.length; i++)
			model.addElement(jList41.getModel().getElementAt(idx[i]));
	}

	//troca de painel quando vc click no avan�ar caso valor 1
	public void changePanel(int i) {
		int oldPanel = currentPanel;
		int newPanel = currentPanel + i;

		if (oldPanel == 0 && newPanel == 1) {
			int indexTarefa = jList1.getSelectedIndex();
			int indexObjeto = jList2.getSelectedIndex();
			if (indexTarefa < 0 || indexObjeto < 0) return;
			objetivo = new Objetivo();
			objetivo.setTarefa((Conceito) jList1.getModel().getElementAt(indexTarefa));
			objetivo.setObjeto((Conceito) jList2.getModel().getElementAt(indexObjeto));
			jLabel21.setText("\"" + objetivo + "\"");

//			List list = ConceitoOWL.recuperarServicos(objetivo);

//			populateJList3(list);
//			populateJList4(list);
//			populateJList31(list);
//			populateJList41(list);

			populateJList3(objetivo);
			populateJList31(objetivo);
			populateJList4(objetivo);
			populateJList41(objetivo);
		}

		if (oldPanel == 1 && newPanel == 2) {
//			int[] indexEntrada = jList3.getSelectedIndices();
//			int[] indexSaida = jList4.getSelectedIndices();
//			int[] indexPrecondicao = jList31.getSelectedIndices();
//			int[] intexPoscondicao = jList41.getSelectedIndices();
//			if (indexEntrada.length == 0 || indexSaida.length == 0) return;

			jLabel31.setText("\"" + objetivo + "\"");
			populateJList5(jList3.getSelectedIndices());
			populateJList6(jList4.getSelectedIndices());
			populateJList51(jList31.getSelectedIndices());
			populateJList61(jList41.getSelectedIndices());
		}

		if (oldPanel == 2 && newPanel == 0) {
			populateJList1();
			populateJList2(-1);
		}

		avancarButton.setEnabled(newPanel < listPanels.size()-1);
		voltarButton.setEnabled(newPanel > 0);
		encerrarButton.setEnabled(newPanel == listPanels.size()-1);

		listPanels.get(oldPanel).setVisible(false);
		listPanels.get(newPanel).setVisible(true);

		currentPanel = newPanel;
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getJToolBarPane(), BorderLayout.SOUTH);
			jContentPane.add(getJCenterPane(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jToolBarPane
	 *
	 * @return javax.swing.JPanel
	 */

	//retorna um barra com butoes
	private JPanel getJToolBarPane() {
		if (jToolBarPane == null) {
			FlowLayout flowLayout = new FlowLayout();
			flowLayout.setAlignment(FlowLayout.RIGHT);
			jToolBarPane = new JPanel();
			jToolBarPane.setLayout(flowLayout);
			jToolBarPane.setPreferredSize(new Dimension(338, 41));
			jToolBarPane.add(getVoltarButton());
			jToolBarPane.add(getAvancarButton());
			jToolBarPane.add(getEncerrarButton());
			jToolBarPane.add(getCancelarButton());
		}
		return jToolBarPane;
	}

	/**
	 * This method initializes voltarButton
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getVoltarButton() {
		if (voltarButton == null) {
			voltarButton = new JButton();
			voltarButton.setText("< Back");
			voltarButton.setEnabled(false);
			voltarButton.setPreferredSize(new Dimension(91, 26));
			voltarButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					changePanel(-1);
				}
			});
		}
		return voltarButton;
	}

	/**
	 * This method initializes avancarButton
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getAvancarButton() {
		if (avancarButton == null) {
			avancarButton = new JButton();
			avancarButton.setText("Next>");
			avancarButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					changePanel(1);
				}
			});
		}
		return avancarButton;
	}

	/**
	 * This method initializes encerrarButton
	 *
	 * @return javax.swing.JButton
	 */
	//Adiciona os conceitos selecionado em objetivo,

	private JButton getEncerrarButton() {
		if (encerrarButton == null) {
			encerrarButton = new JButton();
			encerrarButton.setText("Finish");
			encerrarButton.setEnabled(false);
			encerrarButton.addActionListener(new java.awt.event.ActionListener() {
				//Essa faz toda as operacoes necessaria, quando se click em encerrar
				public void actionPerformed(java.awt.event.ActionEvent e) {
					try {
						DefaultListModel model = (DefaultListModel)jList5.getModel();
						for (int i = 0; i < model.size(); i++) {
							Conceito item = (Conceito) model.get(i);
							objetivo.addEntrada(item);
						}

						model = (DefaultListModel)jList6.getModel();
						for (int i = 0; i < model.size(); i++) {
							Conceito item = (Conceito) model.get(i);
							objetivo.addSaida(item);
						}

						model = (DefaultListModel)jList51.getModel();
						for (int i = 0; i < model.size(); i++) {
							Conceito item = (Conceito) model.get(i);
							objetivo.addPreCondicao(item);
						}

						model = (DefaultListModel)jList61.getModel();
						for (int i = 0; i < model.size(); i++) {
							Conceito item = (Conceito) model.get(i);
							objetivo.addEfeito(item);
						}

//						workflow.addObjetivo(objetivo);
						opcao = JOptionPane.OK_OPTION;
						dispose();
					} catch (Exception ex) {
						JOptionPane.showMessageDialog(TelaAssistenteWorkflow.this, ex.getMessage(),
								"Mensagem", JOptionPane.ERROR_MESSAGE);
					}
				}
			});
		}
		return encerrarButton;
	}

	/**
	 * This method initializes cancelarButton
	 *
	 * @return javax.swing.JButton
	 */
	private JButton getCancelarButton() {
		if (cancelarButton == null) {
			cancelarButton = new JButton();
			cancelarButton.setText("Cancel");
			cancelarButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					opcao = JOptionPane.CANCEL_OPTION;
					dispose();
				}
			});
		}
		return cancelarButton;
	}

	/**
	 * This method initializes jCenterPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJCenterPane() {
		if (jCenterPane == null) {
			jCenterPane = new JPanel();
			jCenterPane.setLayout(new CardLayout());
			jCenterPane.add(getJPanel1(), getJPanel1().getName());
			jCenterPane.add(getJPanel2(), getJPanel2().getName());
			jCenterPane.add(getJPanel3(), getJPanel3().getName());
		}
		return jCenterPane;
	}

	/**
	 * This method initializes jPanel
	 *
	 * @return javax.swing.JPanel
	 */
	//retorna o primeiro painel do assistenteWorkflow
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
			gridBagConstraints7.fill = GridBagConstraints.BOTH;
			gridBagConstraints7.gridy = 1;
			gridBagConstraints7.weightx = 1.0;
			gridBagConstraints7.weighty = 1.0;
			gridBagConstraints7.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints7.insets = new Insets(0, 2, 5, 5);
			gridBagConstraints7.gridx = 1;
			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
			gridBagConstraints6.gridx = 1;
			gridBagConstraints6.insets = new Insets(5, 5, 0, 0);
			gridBagConstraints6.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints6.gridy = 0;
			jLabel2 = new JLabel();
			jLabel2.setText("Select an object:");
			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
			gridBagConstraints5.fill = GridBagConstraints.BOTH;
			gridBagConstraints5.gridy = 1;
			gridBagConstraints5.weightx = 1.0;
			gridBagConstraints5.weighty = 1.0;
			gridBagConstraints5.insets = new Insets(0, 5, 5, 2);
			gridBagConstraints5.gridx = 0;
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 0;
			gridBagConstraints4.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints4.insets = new Insets(5, 5, 0, 0);
			gridBagConstraints4.gridy = 0;
			jLabel1 = new JLabel();
			jLabel1.setText("Select a Task:");
			jPanel1 = new JPanel();
			jPanel1.setLayout(new GridBagLayout());
			jPanel1.setName("jPanel1");
			jPanel1.add(jLabel1, gridBagConstraints4);
			jPanel1.add(getJScrollPane1(), gridBagConstraints5);
			jPanel1.add(jLabel2, gridBagConstraints6);
			jPanel1.add(getJScrollPane2(), gridBagConstraints7);
		}
		return jPanel1;
	}

	/**
	 * This method initializes jScrollPane
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane1() {
		if (jScrollPane1 == null) {
			jScrollPane1 = new JScrollPane();
			jScrollPane1.setViewportView(getJList1());
		}
		return jScrollPane1;
	}

	/**
	 * This method initializes jList
	 *
	 * @return javax.swing.JList
	 */

	//na primeira tela, essa classe retorna a primeira lista,
	// como tambem chama o metodo para popular a segunda lista, dependendo do item selecionado da primeira lista
	private JList getJList1() {
		if (jList1 == null) {
			jList1 = new JList(new DefaultListModel());
			jList1.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
			jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
				public void valueChanged(javax.swing.event.ListSelectionEvent e) {
					int index = jList1.getSelectedIndex();
					populateJList2(index);
				}
			});
		}
		return jList1;
	}

	/**
	 * This method initializes jScrollPane
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane2() {
		if (jScrollPane2 == null) {
			jScrollPane2 = new JScrollPane();
			jScrollPane2.setViewportView(getJList2());
		}
		return jScrollPane2;
	}

	/**
	 * This method initializes jList
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList2() {
		if (jList2 == null) {
			jList2 = new JList(new DefaultListModel());
			jList2.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		}
		return jList2;
	}

	/**
	 * This method initializes jPanel2
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel2() {
		if (jPanel2 == null) {
//			jLabel = new JLabel();
//			jLabel.setText("  * Obrigat�rio para a busca de servi�os");
			jPanel2 = new JPanel();
			jPanel2.setName("jPanel2");
			jPanel2.setLayout(new BorderLayout());
			jPanel2.setBorder(BorderFactory.createEmptyBorder(0, 0, 5, 0));
			jPanel2.add(getJPanel21(), BorderLayout.NORTH);
			jPanel2.add(getJPanel22(), BorderLayout.CENTER);
//			jPanel2.add(jLabel, BorderLayout.SOUTH);
		}
		return jPanel2;
	}

	/**
	 * This method initializes jPanel21
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel21() {
		if (jPanel21 == null) {
			jLabel21 = new JLabel();
			jLabel21.setText(" Objective ");
			jPanel21 = new JPanel();
			jPanel21.setLayout(new BorderLayout());
			jPanel21.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 5));
			jPanel21.add(jLabel21, BorderLayout.WEST);
		}
		return jPanel21;
	}

	/**
	 * This method initializes jPanel22
	 *
	 * @return javax.swing.JPanel
	 */
	//Segunda janela apos apertar o botao avan�ar
	private JPanel getJPanel22() {
		if (jPanel22 == null) {
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 1;
			gridBagConstraints3.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints3.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints3.gridy = 2;
			jLabel41 = new JLabel();
			jLabel41.setText("Effects available:");
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.fill = GridBagConstraints.BOTH;
			gridBagConstraints2.weighty = 1.0;
			gridBagConstraints2.gridx = 1;
			gridBagConstraints2.gridy = 3;
			gridBagConstraints2.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints2.weightx = 1.0;
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.fill = GridBagConstraints.BOTH;
			gridBagConstraints1.weighty = 1.0;
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 3;
			gridBagConstraints1.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints1.weightx = 1.0;
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints.gridy = 2;
			jLabel32 = new JLabel();
			jLabel32.setText("Preconditions available:");
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.gridx = 0;
			gridBagConstraints12.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints12.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints12.gridy = 0;
			jLabel3 = new JLabel();
			jLabel3.setText("Input available: ");
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.fill = GridBagConstraints.BOTH;
			gridBagConstraints11.gridy = 1;
			gridBagConstraints11.weightx = 0.9D;
			gridBagConstraints11.weighty = 1.0;
			gridBagConstraints11.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints11.gridx = 0;
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
			gridBagConstraints10.gridx = 1;
			gridBagConstraints10.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints10.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints10.gridy = 0;
			jLabel4 = new JLabel();
			jLabel4.setText("Outputs available:             ");
			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
			gridBagConstraints9.fill = GridBagConstraints.BOTH;
			gridBagConstraints9.gridy = 1;
			gridBagConstraints9.weightx = 1.0;
			gridBagConstraints9.weighty = 1.0;
			gridBagConstraints9.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints9.gridx = 1;
			jPanel22 = new JPanel();
			jPanel22.setLayout(new GridBagLayout());
			jPanel22.add(getJScrollPane3(), gridBagConstraints11);
			jPanel22.add(jLabel3, gridBagConstraints12);
			jPanel22.add(getJScrollPane4(), gridBagConstraints9);
			jPanel22.add(jLabel4, gridBagConstraints10);
			jPanel22.add(getJScrollPane31(), gridBagConstraints1);
			jPanel22.add(jLabel32, gridBagConstraints);
			jPanel22.add(getJScrollPane41(), gridBagConstraints2);
			jPanel22.add(jLabel41, gridBagConstraints3);
		}
		return jPanel22;
	}

	/**
	 * This method initializes jScrollPane3
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane3() {
		if (jScrollPane3 == null) {
			jScrollPane3 = new JScrollPane();
			jScrollPane3.setViewportView(getJList3());
		}
		return jScrollPane3;
	}

	/**
	 * This method initializes jList3
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList3() {
		if (jList3 == null) {
			jList3 = new JList(new DefaultListModel());
//			jList3.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
		}
		return jList3;
	}

	/**
	 * This method initializes jScrollPane4
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane4() {
		if (jScrollPane4 == null) {
			jScrollPane4 = new JScrollPane();
			jScrollPane4.setViewportView(getJList4());
		}
		return jScrollPane4;
	}

	/**
	 * This method initializes jList4
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList4() {
		if (jList4 == null) {
			jList4 = new JList(new DefaultListModel());
		}
		return jList4;
	}

	/**
	 * This method initializes jPanel3
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			jPanel3 = new JPanel();
			jPanel3.setName("jPanel3");
			jPanel3.setLayout(new BorderLayout());
			jPanel3.add(getJPanel31(), BorderLayout.NORTH);
			jPanel3.add(getJPanel32(), BorderLayout.CENTER);
		}
		return jPanel3;
	}

	/**
	 * This method initializes jPanel31
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel31() {
		if (jPanel31 == null) {
			jLabel31 = new JLabel();
			jLabel31.setText(" Objective ");
			jPanel31 = new JPanel();
			jPanel31.setLayout(new BorderLayout());
			jPanel31.setBorder(BorderFactory.createEmptyBorder(5, 10, 10, 5));
			jPanel31.add(jLabel31, BorderLayout.WEST);
//			jPanel31.add(getJButton(), BorderLayout.EAST);
		}
		return jPanel31;
	}

	/**
	 * This method initializes jButton
	 *
	 * @return javax.swing.JButton
	 */
//	private JButton getJButton() {
//		if (jButton == null) {
//			jButton = new JButton();
//			jButton.setText("Pr�ximo objetivo");
//			jButton.addActionListener(new java.awt.event.ActionListener() {
//				public void actionPerformed(java.awt.event.ActionEvent e) {
//					DefaultListModel model = (DefaultListModel)jList5.getModel();
//					for (int i = 0; i < model.size(); i++) {
//						Conceito item = (Conceito) model.get(i);
//						objetivo.addEntrada(item);
//					}
//
//					model = (DefaultListModel)jList6.getModel();
//					for (int i = 0; i < model.size(); i++) {
//						Conceito item = (Conceito) model.get(i);
//						objetivo.addSaida(item);
//					}
//					workflow.addObjetivo(objetivo);
//					changePanel(-2);
//				}
//			});
//		}
//		return jButton;
//	}

	/**
	 * This method initializes jPanel22
	 *
	 * @return javax.swing.JPanel
	 */
	//3� janela apos do assistente
	private JPanel getJPanel32() {
		if (jPanel32 == null) {
			GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
			gridBagConstraints15.gridx = 1;
			gridBagConstraints15.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints15.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints15.gridy = 2;
			jLabel61 = new JLabel();
			jLabel61.setText("Effect producing:         ");
			GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
			gridBagConstraints14.fill = GridBagConstraints.BOTH;
			gridBagConstraints14.weighty = 1.0;
			gridBagConstraints14.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints14.gridy = 3;
			gridBagConstraints14.gridx = 1;
			gridBagConstraints14.weightx = 1.0;
			GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
			gridBagConstraints13.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints13.gridy = 2;
			gridBagConstraints13.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints13.gridx = 0;
			jLabel51 = new JLabel();
			jLabel51.setText("Preconditions Required: ");
			GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
			gridBagConstraints8.fill = GridBagConstraints.BOTH;
			gridBagConstraints8.weighty = 1.0;
			gridBagConstraints8.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints8.gridx = 0;
			gridBagConstraints8.gridy = 3;
			gridBagConstraints8.weightx = 1.0;
			GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
			gridBagConstraints12.gridx = 0;
			gridBagConstraints12.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints12.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints12.gridy = 0;
			jLabel5 = new JLabel();
			jLabel5.setText("Input required:");
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.fill = GridBagConstraints.BOTH;
			gridBagConstraints11.gridy = 1;
			gridBagConstraints11.weightx = 1.0D;
			gridBagConstraints11.weighty = 1.0;
			gridBagConstraints11.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints11.gridx = 1;
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
			gridBagConstraints10.gridx = 1;
			gridBagConstraints10.anchor = GridBagConstraints.NORTHWEST;
			gridBagConstraints10.insets = new Insets(0, 5, 0, 0);
			gridBagConstraints10.gridy = 0;
			jLabel6 = new JLabel();
			jLabel6.setText("Output producing:");
			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
			gridBagConstraints9.fill = GridBagConstraints.BOTH;
			gridBagConstraints9.gridy = 1;
			gridBagConstraints9.weightx = 1.0D;
			gridBagConstraints9.weighty = 1.0D;
			gridBagConstraints9.insets = new Insets(0, 5, 5, 5);
			gridBagConstraints9.gridx = 0;
			jPanel32 = new JPanel();
			jPanel32.setLayout(new GridBagLayout());
			jPanel32.add(getJScrollPane5(), gridBagConstraints9);
			jPanel32.add(jLabel5, gridBagConstraints12);
			jPanel32.add(getJScrollPane6(), gridBagConstraints11);
			jPanel32.add(jLabel6, gridBagConstraints10);
			jPanel32.add(getJScrollPane51(), gridBagConstraints8);
			jPanel32.add(jLabel51, gridBagConstraints13);
			jPanel32.add(getJScrollPane61(), gridBagConstraints14);
			jPanel32.add(jLabel61, gridBagConstraints15);
		}
		return jPanel32;
	}

	/**
	 * This method initializes jScrollPane5
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane5() {
		if (jScrollPane5 == null) {
			jScrollPane5 = new JScrollPane();
			jScrollPane5.setViewportView(getJList5());
		}
		return jScrollPane5;
	}

	/**
	 * This method initializes jList5
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList5() {
		if (jList5 == null) {
			jList5 = new JList(new DefaultListModel());
			jList5.setBackground(new Color(238, 238, 238));
		}
		return jList5;
	}

	/**
	 * This method initializes jScrollPane6
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane6() {
		if (jScrollPane6 == null) {
			jScrollPane6 = new JScrollPane();
			jScrollPane6.setViewportView(getJList6());
		}
		return jScrollPane6;
	}

	/**
	 * This method initializes jList6
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList6() {
		if (jList6 == null) {
			jList6 = new JList(new DefaultListModel());
			jList6.setBackground(new Color(238, 238, 238));
		}
		return jList6;
	}

	/**
	 * This method initializes jScrollPane31
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane31() {
		if (jScrollPane31 == null) {
			jScrollPane31 = new JScrollPane();
			jScrollPane31.setViewportView(getJList31());
		}
		return jScrollPane31;
	}

	/**
	 * This method initializes jList31
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList31() {
		if (jList31 == null) {
			jList31 = new JList(new DefaultListModel());
		}
		return jList31;
	}

	/**
	 * This method initializes jScrollPane41
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane41() {
		if (jScrollPane41 == null) {
			jScrollPane41 = new JScrollPane();
			jScrollPane41.setViewportView(getJList41());
		}
		return jScrollPane41;
	}

	/**
	 * This method initializes jList41
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList41() {
		if (jList41 == null) {
			jList41 = new JList(new DefaultListModel());
		}
		return jList41;
	}

	/**
	 * This method initializes jScrollPane51
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane51() {
		if (jScrollPane51 == null) {
			jScrollPane51 = new JScrollPane();
			jScrollPane51.setViewportView(getJList51());
		}
		return jScrollPane51;
	}

	/**
	 * This method initializes jList51
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList51() {
		if (jList51 == null) {
			jList51 = new JList(new DefaultListModel());
			jList51.setBackground(new Color(238, 238, 238));
		}
		return jList51;
	}

	/**
	 * This method initializes jScrollPane61
	 *
	 * @return javax.swing.JScrollPane
	 */
	private JScrollPane getJScrollPane61() {
		if (jScrollPane61 == null) {
			jScrollPane61 = new JScrollPane();
			jScrollPane61.setViewportView(getJList61());
		}
		return jScrollPane61;
	}

	/**
	 * This method initializes jList61
	 *
	 * @return javax.swing.JList
	 */
	private JList getJList61() {
		if (jList61 == null) {
			jList61 = new JList(new DefaultListModel());
			jList61.setBackground(new Color(238, 238, 238));
		}
		return jList61;
	}

}
